package model.User;


import model.User.entity.User;
import model.User.mapper.UserMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;

/**
 * Created by Sunshine、宸 on 2019/6/24.
 */

@RunWith(SpringRunner.class)
@SpringBootTest
public class testUserMapper {

        @Autowired
        private UserMapper userMapper;
        @Test
        public void findAll(){
            System.out.println(userMapper.findAll());
        }

        @Test
        public void findById(){
            System.out.println(userMapper.findById(1));
        }

        @Test
        public void Testsave(){
            User user=new User();
            //user.setUserId(3);
            user.setUserName("jack");
            user.setUserEmail("11456454@qq.com");
            user.setUserPhone("1211");
            user.setUserSex(0);
            user.setUserPassword("jack");
            user.setUserConfirmpwd("jack");
            //user.setUserIdwork();
            //user.setUserSex(0);
//            System.out.println(user);
            userMapper.Save(user);
        }

        @Test
        public void testDelById(){
            userMapper.delById(5);
        }

        @Test
        public void testfindMoHu(){
            System.out.println(userMapper.findMoHu("k"));
        }

        @Test
        public void testUpdate() {
          User user=userMapper.findById(2);
            System.out.println(user);
          user.setUserName("lio");
          user.setUserEmail("1747986188@qq.com");
//            user.setUserAge(40);
          userMapper.updateUser(user);
        }

    @Test
    public void testfindByPhone(){
        System.out.println(userMapper.findByPhone("18261687290"));
    }

    @Test
    public void testfindByEmail(){
        User user=new User();
        user.setUserPhone("18261687290");
        System.out.println(userMapper.findByEmail(user));
    }

    @Test
    public void testfindByUserName(){
        System.out.println(userMapper.findByUserName("tom"));
    }
}
